home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / Direct3D / DXTex / MainFrm.cpp < prev    next >
C/C++ Source or Header  |  2001-10-08  |  3KB  |  118 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "dxtex.h"
  6. #include "MainFrm.h"
  7. #include "DxtexDoc.h"
  8. #include "DxtexView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CMainFrame
  18.  
  19. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  20.  
  21. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  22.     //{{AFX_MSG_MAP(CMainFrame)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code !
  25.     ON_WM_CREATE()
  26.     //}}AFX_MSG_MAP
  27.     ON_UPDATE_COMMAND_UI(ID_INDICATOR_IMAGEINFO, OnUpdateImageInfo)
  28. END_MESSAGE_MAP()
  29.  
  30. static UINT indicators[] =
  31. {
  32.     ID_SEPARATOR,           // status line indicator
  33.     ID_INDICATOR_IMAGEINFO,
  34. };
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CMainFrame construction/destruction
  38.  
  39. CMainFrame::CMainFrame()
  40. {
  41. }
  42.  
  43. CMainFrame::~CMainFrame()
  44. {
  45. }
  46.  
  47. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  48. {
  49.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  50.         return -1;
  51.     
  52. // Note: I changed the default toolbar creation code so we can still compile with VC5:
  53. //    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  54. //        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  55. //        !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  56.     if (!m_wndToolBar.Create(this) ||
  57.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  58.     {
  59.         TRACE0("Failed to create toolbar\n");
  60.         return -1;      // fail to create
  61.     }
  62.  
  63.     if (!m_wndStatusBar.Create(this) ||
  64.         !m_wndStatusBar.SetIndicators(indicators,
  65.           sizeof(indicators)/sizeof(UINT)))
  66.     {
  67.         TRACE0("Failed to create status bar\n");
  68.         return -1;      // fail to create
  69.     }
  70.  
  71.     m_wndStatusBar.SetPaneInfo(1, ID_INDICATOR_IMAGEINFO, SBPS_NORMAL, 220);
  72.  
  73.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  74.     EnableDocking(CBRS_ALIGN_ANY);
  75.     DockControlBar(&m_wndToolBar);
  76.  
  77.     return 0;
  78. }
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CMainFrame diagnostics
  82.  
  83. #ifdef _DEBUG
  84. void CMainFrame::AssertValid() const
  85. {
  86.     CMDIFrameWnd::AssertValid();
  87. }
  88.  
  89. void CMainFrame::Dump(CDumpContext& dc) const
  90. {
  91.     CMDIFrameWnd::Dump(dc);
  92. }
  93.  
  94. #endif //_DEBUG
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CMainFrame message handlers
  98. void CMainFrame::OnUpdateImageInfo(CCmdUI *pCmdUI)
  99. {
  100.     CString strInfo;
  101.  
  102.     // Get the active MDI child window.
  103.     CMDIChildWnd *pChild = (CMDIChildWnd *)GetActiveFrame();
  104.  
  105.     if (pChild != NULL && pChild != (CMDIChildWnd *)this)
  106.     {
  107.         // Get the active view attached to the active MDI child window.
  108.         CDxtexView* pView = (CDxtexView*)pChild->GetActiveView();
  109.         pView->GetImageInfo(strInfo);
  110.         pCmdUI->Enable(); 
  111.         pCmdUI->SetText(strInfo);
  112.     }
  113.     else
  114.     {
  115.         pCmdUI->Enable(FALSE); 
  116.     }
  117. }
  118.